<template>
    <div class="box">
        <header>
            <van-nav-bar title="全部订单" @click-left="$router.back()">
                <template #left>
                    <van-icon name="arrow-left" size="18" color="black" />
                </template>
            </van-nav-bar>
        </header>
        <main>
            <div class="searchbox">
                <van-search v-model="value" shape="round" placeholder="请输入搜索关键词" />
                <div class="van-hairline--bottom"></div>
            </div>
            <div class="orderbox">
                <van-card :num="item.num" :price="item.originprice" :title="item.proname" :thumb="item.img1"
                    v-for="(item, index) in orderList" :key='index'>
                </van-card>
            </div>
            <van-divider>没有更多订单了~</van-divider>
        </main>
    </div>
</template>

<script>
import { getOrderList } from '../api/order'
export default {
    data() {
        return {
            orderList: []
        }
    },
    created() {
        getOrderList({ userid: localStorage.getItem('userid') }).then(res => {
            if (res.data.code == 200) {
                this.orderList = res.data.data
                console.log(this.orderList);
            }
        })
    },
    onSubmit(){
      addOrder({userid:localStorage.getItem('userid')}).then(res=>{
        console.log(res.data.time);
        if(res.data.code=='200'){
          this.$router.push('/orderlist/')
        }
      })
    }
}
</script>

<style scoped>
.box {
    display: flex;
    flex-direction: column;
}

main {
    background-color: rgb(240, 240, 240);
    height: 50%;
    flex: 1;
    overflow-y: auto;
}

.van-card {
    background-color: #fff;
    margin: .08rem 0.02rem;
    border-radius: .05rem;
}
</style>